﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using BCCommon;
using BCDto.OA.BusinessFlowModel.BusinessFlowStepModel;
using BCService.OA.BusinessFlowModel.BusinessFlowStepModel;
using BCService.Utils;
using BlackCoffeeRESTful.Configs;

namespace BlackCoffeeRESTful.Controllers.Management.OA.BusinessFlowModel.BusinessFlowStepModel
{
    /// <summary>
    /// OA系统业务流步骤模型
    /// </summary>
    [ApiExplorerSettings(GroupName = "OAAdmin")]
    [Route("api/v1/sim/[controller]")]
    public class BusinessFlowStepModelController : ManagementBaseController
    {
        private readonly IBusinessFlowStepModelService businessFlowStepModelService;

        public BusinessFlowStepModelController(IBusinessFlowStepModelService businessFlowStepModelService)
        {
            this.businessFlowStepModelService = businessFlowStepModelService;
        }

        #region 添加OA系统业务流步骤模型
        /// <summary>
        ///  添加OA系统业务流步骤模型
        /// </summary>
        /// <param name="requestDto">OA系统业务流步骤模型信息</param>
        /// <response code="201">添加OA系统业务流步骤模型成功</response>
        /// <returns></returns>
        [HttpPost]
        [Log("添加OA系统业务流步骤模型")]
        [ProducesResponseType(typeof(BusinessFlowStepModelDto), 201)]
        public IActionResult Post(
            [FromBody]BusinessFlowStepModelRequestDto requestDto)
        {
            var result = this.businessFlowStepModelService.Add(requestDto);
            return this.Created(string.Format("api/v1/sim/BusinessFlowStepModel/{0}", result.BusinessFlowStepModelId), result);
        }
        #endregion

        #region 修改OA系统业务流步骤模型
        /// <summary>
        ///  修改OA系统业务流步骤模型
        /// </summary>
        /// <param name="businessFlowStepModelId">OA系统业务流步骤模型Id</param>
        /// <param name="requestDto">OA系统业务流步骤模型信息</param>
        /// <response code="200">修改OA系统业务流步骤模型成功</response>
        /// <returns></returns>
        [HttpPut("{business_flow_step_model_id}")]
        [Log("修改OA系统业务流步骤模型")]
        [ProducesResponseType(typeof(BusinessFlowStepModelDto), 200)]
        public IActionResult Post([FromRoute(Name = "business_flow_step_model_id")]long businessFlowStepModelId, [FromBody]BusinessFlowStepModelRequestDto requestDto)
        {
            BusinessFlowStepModelPutDto putDto = requestDto.As<BusinessFlowStepModelPutDto>();
            putDto.BusinessFlowStepModelId = businessFlowStepModelId;
            return this.Ok(this.businessFlowStepModelService.Update(putDto));
        }
        #endregion

        #region 删除OA系统业务流步骤模型
        /// <summary>
        ///  删除OA系统业务流步骤模型
        /// </summary>
        /// <param name="businessFlowStepModelId">OA系统业务流步骤模型Id</param>
        /// <response code="204">删除OA系统业务流步骤模型成功</response>
        /// <returns></returns>
        [HttpDelete("{business_flow_step_model_id}")]
        [Log("删除OA系统业务流步骤模型")]
        public IActionResult Delete([FromRoute(Name = "business_flow_step_model_id")]long businessFlowStepModelId)
        {
            this.businessFlowStepModelService.Delete(businessFlowStepModelId);
            return this.NoContent();
        }
        #endregion

        #region 获取OA系统业务流步骤模型
        /// <summary>
        ///  获取OA系统业务流步骤模型
        /// </summary>
        /// <param name="businessFlowStepModelId">OA系统业务流步骤模型Id</param>
        /// <response code="200">获取OA系统业务流步骤模型</response>
        /// <returns></returns>
        [HttpGet("{business_flow_step_model_id}")]
        [ProducesResponseType(typeof(BusinessFlowStepModelDto), 200)]
        public IActionResult Get([FromRoute(Name = "business_flow_step_model_id")]long businessFlowStepModelId)
        {
            return this.Ok(this.businessFlowStepModelService.GetEntity(businessFlowStepModelId));
        }
        #endregion

        #region 获取OA系统业务流步骤模型列表
        /// <summary>
        ///  获取OA系统业务流步骤模型列表
        /// </summary>
        /// <param name="businessFlowModelId">业务流模型Id</param>
        /// <response code="200">获取OA系统业务流步骤模型列表</response>
        /// <returns></returns>
        [HttpGet("[action]/{business_flow_model_id}")]
        [ProducesResponseType(typeof(BusinessFlowStepModelDto), 200)]
        public IActionResult BusinessFlowModel([FromRoute(Name ="business_flow_model_id")]long businessFlowModelId)
        {
            return this.Ok(this.businessFlowStepModelService.GetList(businessFlowModelId));
        }
        #endregion

        #region 获取OA系统业务流步骤模型（分页）
        /// <summary>
        ///  获取OA系统业务流步骤模型（分页）
        /// </summary>
        /// <param name="businessFlowModelId">业务流模型Id</param>
        /// <param name="businessFlowStepModelName">OA系统业务流步骤模型名称</param>
        /// <param name="businessFlowModelName">业务流模型名称</param>
        /// <param name="start">开始时间</param>
        /// <param name="end">结束时间</param>
        /// <param name="pageIndex">以 1 起始的页码 (默认 1)。</param>
        /// <param name="pageSize">每页要显示的行数 (默认 10)。</param>
        /// <response code="200">获取OA系统业务流步骤模型（分页）</response>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(PageableList<BusinessFlowStepModelDto>), 200)]
        public IActionResult Query(
            [FromQuery(Name = "business_flow_model_id")]long? businessFlowModelId,
            [FromQuery(Name = "business_flow_step_model_name")]string businessFlowStepModelName,
            [FromQuery(Name = "business_flow_model_name")]string businessFlowModelName,
            [FromQuery(Name = "start")]DateTime? start,
            [FromQuery(Name = "end")]DateTime? end,
            int pageIndex = 1,
            int pageSize = 10)
        {
            return this.Ok(this.businessFlowStepModelService.Query(businessFlowModelId,businessFlowStepModelName, businessFlowModelName, start, end, pageIndex, pageSize));
        }
        #endregion

    }
}
